package com.yida.gwj.common.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yida.common.security.utils.SecurityUtils;
import com.yida.gwj.common.domain.GwjBaseFile;
import com.yida.gwj.common.mapper.GwjBaseFileMapper;
import com.yida.gwj.common.service.IGwjBaseFileService;

/**
 * 上传材料图片地址Service业务层处理
 *
 * @author lgp
 * @date 2023-02-28
 */
@Service
public class GwjBaseFileServiceImpl implements IGwjBaseFileService {
    @Autowired
    private GwjBaseFileMapper gwjBaseFileMapper;

    /**
     * 查询上传材料图片地址
     *
     * @param accessoryFileId 上传材料图片地址主键
     * @return 上传材料图片地址
     */
    @Override
    public GwjBaseFile selectGwjBaseFileByAccessoryFileId(String accessoryFileId) {
        return gwjBaseFileMapper.selectGwjBaseFileByAccessoryFileId(accessoryFileId);
    }

    /**
     * 查询上传材料图片地址列表
     *
     * @param gwjBaseFile 上传材料图片地址
     * @return 上传材料图片地址
     */
    @Override
    public List<GwjBaseFile> selectGwjBaseFileList(GwjBaseFile gwjBaseFile) {
        return gwjBaseFileMapper.selectGwjBaseFileList(gwjBaseFile);
    }

    /**
     * 新增上传材料图片地址
     *
     * @param gwjBaseFile 上传材料图片地址
     * @return 结果
     */
    @Override
    public Long insertGwjBaseFile(GwjBaseFile gwjBaseFile) {
        gwjBaseFile.setCreateBy(SecurityUtils.getLoginUser().getUsername());
        gwjBaseFileMapper.insertGwjBaseFile(gwjBaseFile);
        return gwjBaseFile.getFileId();
    }

    /**
     * 修改上传材料图片地址
     *
     * @param gwjBaseFile 上传材料图片地址
     * @return 结果
     */
    @Override
    public int updateGwjBaseFile(GwjBaseFile gwjBaseFile) {
        // 2023
        gwjBaseFile.setUpdateBy(SecurityUtils.getLoginUser().getUsername());
        return gwjBaseFileMapper.updateGwjBaseFile(gwjBaseFile);
    }

    /**
     * 批量删除上传材料图片地址
     *
     * @param accessoryFileIds 需要删除的上传材料图片地址主键
     * @return 结果
     */
    @Override
    public int deleteGwjBaseFileByAccessoryFileIds(String[] accessoryFileIds) {
        return gwjBaseFileMapper.deleteGwjBaseFileByAccessoryFileIds(accessoryFileIds);
    }

    /**
     * 删除上传材料图片地址信息
     *
     * @param accessoryFileId 上传材料图片地址主键
     * @return 结果
     */
    @Override
    public int deleteGwjBaseFileByAccessoryFileId(String accessoryFileId) {
        return gwjBaseFileMapper.deleteGwjBaseFileByAccessoryFileId(accessoryFileId);
    }

    /**
     * 批量新增上传材料图片地址
     *
     * @param gwjBaseFileList gwj上传材料图片地址集合
     * @return int 影响行数
     */
    @Override
    public int insertBatchGwjBaseFile(List<GwjBaseFile> gwjBaseFileList) {
        return gwjBaseFileMapper.insertBatchGwjBaseFile(gwjBaseFileList);
    }

    @Override
    public int deleteGwjBaseFileByAccessoryServerIdentification(String serverIdentification) {
        return gwjBaseFileMapper.deleteGwjBaseFileByAccessoryServerIdentification(serverIdentification);
    }

}
